<style scoped>
h2 {
  text-align: center;
  padding: 30px;
  font-size: 18px;
}
#chart_example {
  width: 90%;
  height: 700px;
  /*border: 1px solid red;*/
  margin: 0 auto;
}
</style>
<template>
  <div>
    <el-card>
      <div id="chart_example"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: 'Chart',
  data() {
    return {};
  },
  mounted() {
    let myChart = echarts.init(document.getElementById("chart_example"));
    //let option = {
    //  color: ['#f44'],
    //  tooltip : {
    //    trigger: 'axis',
    //    axisPointer : {
    //      type : 'shadow'
    //    }
    //  },
    //  xAxis : [
    //    {
    //      type : 'category',
    //      data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月',],
    //      axisTick: {
    //        alignWithLabel: true
    //      }
    //    }
    //  ],
    //  yAxis : [
    //    {
    //      type : 'value'
    //    }
    //  ],
    //  series : [
    //    {
    //      name:'每月花费',
    //      type:'bar',
    //      barWidth: '60%',
    //      data:[995,666,444,858,654,236,645,546,846,225,547,356]
    //    }
    //  ]
    //};

    let option = {
      title: {
        text: "Stacked Line",
      },
      tooltip: {
        trigger: "axis",
      },
      legend: {
        data: ["Email", "Union Ads", "Video Ads", "Direct", "Search Engine"],
      },
      grid: {
        left: "2%",
        right: "2%",
        bottom: "8%",
        containLabel: true,
      },
      toolbox: {
        feature: {
          saveAsImage: {},
        },
      },
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          name: "Email",
          type: "line",
          stack: "Total",
          data: [120, 132, 101, 134, 90, 230, 210],
        },
        {
          name: "Union Ads",
          type: "line",
          stack: "Total",
          data: [220, 182, 191, 234, 290, 330, 310],
        },
        {
          name: "Video Ads",
          type: "line",
          stack: "Total",
          data: [150, 232, 201, 154, 190, 330, 410],
        },
        {
          name: "Direct",
          type: "line",
          stack: "Total",
          data: [320, 332, 301, 334, 390, 330, 320],
        },
        {
          name: "Search Engine",
          type: "line",
          stack: "Total",
          data: [820, 932, 901, 934, 1290, 1330, 1320],
        }
      ]
    }
    myChart.setOption(option)

    window.addEventListener("resize", function () {
      myChart.resize();
    })
  }
}
</script>
